// eslint-disable-next-line
import { UserLayout, BasicLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/workplace',
        component: RouteView,
        meta: { title: 'menu.dashboard', keepAlive: true, icon: 'dashboard', permission: ['dashboard'] },
        children: [
          {
            path: '/dashboard/workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: ['dashboard'] }
          },
          {
            path: '/dashboard/analysis/:pageNo([1-9]\\d*)?',
            name: 'Analysis',
            component: () => import('@/views/dashboard/Analysis'),
            meta: { title: 'menu.dashboard.analysis', keepAlive: false, permission: ['dashboard'] }
          }
        ]
      },

      // 全局管理
      {
        path: '/overall',
        name: 'overall',
        component: RouteView,
        meta: { title: 'overall.home', icon: 'setting' },
        redirect: '/overall/site',
        children: [
          {
            path: '/overall/site',
            name: 'site',
            meta: { title: 'overall.site', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/overall/site')
          }, {
            path: '/overall/reg',
            name: 'reg',
            meta: { title: 'overall.reg', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/overall/reg')
          }, {
            path: '/overall/annex',
            name: 'annex',
            meta: { title: 'overall.annex', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/overall/annex')
          }
        ]
      },

      // 用户管理
      {
        path: '/member',
        name: 'member',
        component: RouteView,
        meta: { title: 'member.home', icon: 'user' },
        redirect: '/member/manage',
        children: [
          {
            path: '/member/manage',
            name: 'manage',
            meta: { title: 'member.manage', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/member/manage')
          }, {
            path: '/member/role',
            name: 'role',
            meta: { title: 'member.role', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/member/role')
          }, {
            path: '/member/verify',
            name: 'verify',
            meta: { title: 'member.verify', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/member/verify')
          }
        ]
      },

      // 内容管理
      {
        path: '/posts',
        name: 'posts',
        component: RouteView,
        meta: { title: 'posts.home', icon: 'container' },
        redirect: '/posts/classify',
        children: [
          {
            path: '/posts/classify',
            name: 'classify',
            meta: { title: 'posts.classify', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/posts/classify')
          }, {
            path: '/posts/post',
            name: 'posts',
            meta: { title: 'posts.post', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/posts/post')
          }, {
            path: '/posts/examine',
            name: 'examine',
            meta: { title: 'posts.examine', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/posts/examine')
          }, {
            path: '/posts/topic',
            name: 'topic',
            meta: { title: 'posts.topic', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/posts/topic')
          }, {
            path: '/posts/recycle',
            name: 'recycle',
            meta: { title: 'posts.recycle', keepAlive: true, permission: ['dashboard'] },
            component: () => import('@/views/posts/recycle')
          }
        ]
      }

    ]
  },
  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
